#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=8005;
int n,q,ans[MAXN];
inline int Read() {
	int x=0,c=getchar(),f=1;
	for(; c<=47||c>=58; c=getchar())f=f&&(c^45);
	for(; c>=48&&c<=57; c=getchar())x=(x<<3)+(x<<1)+(c&15);
	return f?x:-x;
}
struct node {
	int val,id;
	bool operator<(const node &b) const {
		return val^b.val?val<b.val:id<b.id;
	}
} p[MAXN];
int main() {
	freopen("sort.in","r",stdin);
	freopen("sort.out","w",stdout);
	scanf("%d%d",&n,&q);
	for(int i=1; i<=n; ++i) {
		p[i].val=Read();
		p[i].id=i;
	}
	stable_sort(p+1,p+n+1);
	for(int j=1; j<=n; ++j)
		ans[p[j].id]=j;
	for(int i=1,op,x,y; i<=q; ++i) {
		op=Read(),x=Read();
		if(op==1) {
			y=Read();
			p[ans[x]].val=y;
			int l=ans[x],r=ans[x];
			while(l>0&&p[l]<p[l-1]) {
				--l;
				swap(p[l],p[l+1]);
			}
			while(r<n&&p[r+1]<p[r]) {
				swap(p[r],p[r+1]);
				++r;
			}
			for(int j=l; j<=r; ++j)
				ans[p[j].id]=j;
		} else if(op==2) {
			printf("%d\n",ans[x]);
		}
	}
	return 0;
}
